let app = getApp()
Component({
    properties: {
         type:String
      },
      data:{
      status:1,
      tabBarList: [ {
          id: "1",
          title: "正在进行"
      }, {
          id: "2",
          title: "已结束"
      } ],
      list: [],
      page:1,
      page_path: "pages/seckill-list/seckill-list",
      timer: null,
      statusCur: 0,
      activityMap: {
          seckill: {
              buttonText: "去秒杀",
              api: "Seckill_getSeckillList"
          },
          seckill_list: {
            buttonText: "去秒杀",
            api: "Seckill_getSeckillList"
         },
          group_list: {
              buttonText: "去拼团",
              api: "Group_getGroupList"
          },
          group: {
            buttonText: "去拼团",
            api: "Group_getGroupList"
          },
          bargain: {
              buttonText: "去砍价",
              api: "Bargain_getBargainList"
          },
          bargain_list: {
            buttonText: "去砍价",
            api: "Bargain_getBargainList"
        }
      }
      },
    lifetimes: {
        attached: function () {
              this.get_data();
       }
      },
    methods: {
      catlist:function(e){
        this.setData({
          list:[]
        })
        this.setData({
          status:parseInt(e.detail.catid) 
        })
        this.get_data()
      },
      get_data:function(){
        var that=this
        if(this.data.type=='group_list'){
          wx.request({
            url: app.globalData.siteroot,
            data: { 
              do:'Group_getGroupList',
              status:that.data.status,
              page:that.data.page,
              page_size:20
            },
            success: function(res) {
                that.setData({
                  list:res.data.data,
                  activeType:'group'
                })
            }
          })
        }
        if(this.data.type=='seckill_list'){
          wx.request({
            url: app.globalData.siteroot,
            data: { 
              do:'Seckill_getSeckillList',
              status:that.data.status,
              page:that.data.page,
              page_size:20
            },
            success: function(res) {
                that.setData({
                  list:res.data.data,
                  activeType:'seckill'
                })
            }
          })
        }
        if(this.data.type=='bargain_list'){
          wx.request({
            url: app.globalData.siteroot,
            data: { 
              do:'Bargain_getBargainList',
              status:that.data.status,
              page:that.data.page,
              page_size:20
            },
            success: function(res) {
                console.log(res.data.data)
                that.setData({
                  list:res.data.data,
                  activeType:'bargain'
                })
            }
          })
        }
      }
    }
});
